
//package com.junan.wms.utils;
//
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.core.type.TypeReference;
//import io.qameta.allure.internal.shadowed.jackson.core.JsonParser;
//import io.qameta.allure.internal.shadowed.jackson.databind.DeserializationFeature;
//import io.qameta.allure.internal.shadowed.jackson.databind.JavaType;
//import io.qameta.allure.internal.shadowed.jackson.databind.ObjectMapper;
//import lombok.NonNull;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.util.List;
//import java.util.Map;
//
//
//public class JsonUtil {
//    private static Logger logger = LoggerFactory.getLogger(JsonUtil.class);
//
//    private final static ObjectMapper objectMapper = new ObjectMapper();
//
//    static {
//        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
////
//        objectMapper.configure(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY, true);
////
//        //允许出现特殊字符和转义符
////        objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true) ;
//
//        //允许出现单引号
//        objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true) ;
//
//        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//
//    }
//
//    private JsonUtil() {
//
//    }
//
////    public static ObjectMapper getObjectMapper() {
////        return objectMapper;
////    }
////
////    public static String toJson(Object obj) {
////        String result = null;
////        try {
////            result = objectMapper.writeValueAsString(obj);
////        } catch (JsonProcessingException e) {
////            logger.warn(e.toString());
////        }
////        return result;
////    }
//
////    public static <T> T fromJson(String jsonStr, Class<T> clazz) {
////        T result = null;
////        try {
////            result = objectMapper.readValue(jsonStr, clazz);
////        } catch (JsonProcessingException e) {
////            e.printStackTrace();
////        }
////
//////        return result;
////    }
//
////    public static <T> T fromJson(String jsonStr, TypeReference<T> valueTypeRef)
////            throws Exception {
////        return objectMapper.readValue(jsonStr, valueTypeRef);
////    }
//
////    public static <T> Map<String, T> jsonToMap(String jsonStr) {
////        Map<String, T> result = null;
////        try {
////            result = objectMapper.readValue(jsonStr, new TypeReference<Map<String, T>>() {});
////        } catch (JsonProcessingException e) {
////            logger.warn(e.toString());
////        }
////
////        return result;
////    }
//
////    public static <T> List<T> jsonToList(@NonNull String jsonString, Class<T> cls) {
////        try {
////            return objectMapper.readValue(jsonString, getCollectionType(List.class, cls));
////        } catch (JsonProcessingException e) {
////            logger.warn(e.toString());
////        }
////        return null;
////    }
//
//    private static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
//        return objectMapper.getTypeFactory().constructParametricType(collectionClass, elementClasses);
//    }
//
////    public static List<Map<String, Object>> jsonToListOfMap(String jsonStr) {
////        List<Map<String, Object>> list = null;
////        try {
////            list = objectMapper.readValue(jsonStr,
////                    new TypeReference<List<Map<String, Object>>>() {
////                    });
////        } catch (JsonProcessingException e) {
////            logger.warn(e.toString());
////        }
////        return list;
////    }
//
//
//}